'''
Created on 31/07/2011

@author: Digao
'''
def toInt(arg):
    return int(arg)

def toStr(a,b):
    return str(a)+' '+str(b)

def scalar(va,vb):
    sum=0
    for i in range(len(va)):
        sum+=va[i]*vb[i]
    return sum

MATCH = 'welcome to code jam'

input = open('input.in')
CASES = int(input.readline())
for case in range(1,CASES+1):
    size = int(input.readline())
    v1 = map(toInt,input.readline().strip().split())
    v2 = map(toInt,input.readline().strip().split())
    v1.sort()
    v2.sort(reverse=True)
    print 'Case #%d: %d'%(case,scalar(v1,v2))
    


